import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

App.mpType = 'app'

Vue.prototype.turnPage = (pageUrl,param) => {
	let _url = ''
	if (param) {
		_url = '/pages/' + pageUrl + '?param=' + encodeURIComponent(JSON.stringify(param))
	}else {
		_url = '/pages/' + pageUrl
	}
	uni.navigateTo({
		url: _url
	})
}

Vue.prototype.add0 = (m) => {
	return m<10?('0'+m):m
}

Vue.prototype.dateFormat = (timestamp) => {
	//shijianchuo是整数，否则要parseInt转换
	let time = new Date(timestamp)
	let y = time.getFullYear()
	let m = time.getMonth()+1
	let d = time.getDate()
	let h = time.getHours()
	let mm = time.getMinutes()
	let s = time.getSeconds()
	return (y<10?('0'+ y):y) +'-'+(m<10?('0'+ m):m)+'-'+(d<10?('0'+d):d)+' '+(h<10?('0'+h):h)+':'+(mm<10?('0'+mm):mm)+':'+(s<10?('0'+s):s)
}

Vue.prototype.switchTabPage = (pageUrl) => {
	uni.switchTab({
		url: '/pages/' + pageUrl + '/index'
	})
}

Vue.prototype.redirectToPage = (pageUrl) => {
	uni.redirectTo({
		url: '/pages/' + pageUrl + '/index'
	})
}

const app = new Vue({
	...App
})
app.$mount()
